{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="ibox-title">
        <h5>编辑型号</h5>
    </div>
    <div class="ibox-content layui-form">
        <div class="layui-row layui-col-space10 layui-form-item ">

            <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                <label class="layui-form-label">型号名称：</label>
                <div class="layui-input-block">
                    <input type="text" name="xh_name" value="{$xh.device_name}" lay-verify="required" placeholder="型号名称" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                <label class="layui-form-label">故障：</label>
                <div class="layui-input-block">
                    <select name="device_gz" xm-select="select" xm-select-search="" xm-select-search-type="dl">
                        <option value="">---- 请选择故障 ----</option>
                        {foreach name="gz" item="v"}
                        <option value="{$v.gz_id}" {in name="$v.gz_id" value="$xh.device_gz"} selected {/in}>{$v.gz_name}</option>
                        {/foreach}
                    </select>
                </div>
            </div>

            <input type="hidden" value="{$xh_id}" name="xh_id">

            <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit="" lay-filter="component-form-element">保存
                    </button>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script>
    layui.use(['form'], function() {
        var form = layui.form;
        form.on('submit(component-form-element)', function (data) {
            $('.layui-btn').addClass('layui-disabled').attr('disabled','disabled');
            $.ajax({
                url:"{:url('xhUpdate')}",
                type:'post',
                dataType:'json',
                data:data.field,
                success:function(res){
                    if (res.code == 200) {
                        layer.msg(res.msg,{icon:1,time:1500,shade:0.1},function(index){
                            wk.layer_close();
                        });
                    } else {
                        wk.error(res.msg,'','$(".layui-btn").removeClass(\'layui-disabled\').removeAttr(\'disabled\')');
                    }
                }
            })
        });
    });
</script>
</body>
</html>